package com.lemon.exam.service.impl;

import com.lemon.exam.common.crud.BaseServiceImpl;
import com.lemon.exam.entity.po.UserRolePO;
import com.lemon.exam.repository.UserRoleRepository;
import com.lemon.exam.service.IUserRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * 用户角色中间表 服务实现类
 *
 * @author Lemon
 * @since 2025/04/04 14:23:21
 */
@Slf4j
@Service
public class UserRoleServiceImpl extends BaseServiceImpl<UserRolePO, String, UserRoleRepository> implements IUserRoleService {
    @Override
    public Mono<Boolean> saveAll(List<UserRolePO> userRoleList) {
        return repository.saveAll(userRoleList).collectList().map(count -> count.size() == userRoleList.size());
    }

    @Override
    public Mono<Boolean> deleteByUserId(Long userId) {
        return repository.deleteAllByUserId(userId).thenReturn(true);
    }
}
